extends Node2D


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	GameUtiles.player_bag = {}
	GameUtiles.ingredients = []
	DialogueManager.show_dialogue_balloon(load("res://dialogues/dia_in_levels/start.dialogue"),"start")
	$map/bridge.hide()
	

func _process(delta: float) -> void:
		if GameUtiles.l1_biult == true:
				$map/bridge.show()




#1to2判定、传送
func _on_body_entered(body: Node2D) -> void:
	if body.name =="player" and GameUtiles.move_allow and GameUtiles.l1_biult:
		print("1to2")
		get_tree().change_scene_to_file("res://scenes/level_2.tscn")




var player_in_range:bool=false
#造桥判定
func _on_area_2d_body_entered(body: Node2D) -> void:
	if body.name =="player":
		player_in_range=true
		
func _on_area_2d_body_exited(body: Node2D) -> void:
	if body.name =="player":
		player_in_range=false

func _input(event):
	if not GameUtiles.l1_biult:
		if event.is_action_pressed("build") and player_in_range and GameUtiles.move_allow:
			if GameUtiles.player_bag.get("wooden",0) > 0 or GameUtiles.ingredients.has("wooden"):
				DialogueManager.show_dialogue_balloon(load("res://dialogues/dia_in_levels/l1_build_bridge.dialogue"),"start")
		if event.is_action_pressed("build") and not player_in_range and GameUtiles.move_allow:
			print("不在监测点")


		
		
		
		
		
